<?php
/*
 * Generic DB Wrapper for YappFramework
 *
 * NOT USED! Will be casted always to type depeding on current engine
 *
 * Extends abstract classyappDBWrapper and defines singleton pattern functionallity
 *
 */

class genericDBWrapper
{

    // Instances
    private static $_instances       = array();
    private static $_currentInstance = false;

    // Get instace for singleton pattern
    public static function getInstance($engine = false, $conf = false)
    {
        if (!empty($engine) && (empty($conf)))
        {
            die("No configuration for new engine instance!");
        }
        else if ((!empty($engine)) && (!isset(self::$_instances[$engine])))
        {
            $wrapper = $engine.'DBWrapper';
            self::$_instances[$wrapper] = new $wrapper($conf);
            self::$_instances[$wrapper]->setInstanceHash();
            if (!self::$_currentInstance)
            {
                self::$_currentInstance = $wrapper;
            }
            return self::$_instances[$wrapper];
        }
        else
        {
            if (!empty($engine))
            {
                $wrapper = $engine.'DBWrapper';
                return self::$_instances[$wrapper];
            }
            else
            {
                return self::$_instances[self::$_currentInstance];
            }
        }
    }


}

?>